
import Logs, Options, sys
import samba3

def set_options(opt):
    help =  "Build with gpgme support (default=auto). "
    help += "This requires gpgme devel and python packages "
    help += "(e.g. libgpgme11-dev, python-gpgme on debian/ubuntu)."

    opt.SAMBA3_ADD_OPTION('gpgme', default=None, help=(help))

    return

def configure(conf):
    conf.SET_TARGET_TYPE('gpgme', 'EMPTY')

    if Options.options.with_gpgme != False:
        conf.find_program('gpgme-config', var='GPGME_CONFIG')

        if conf.env.GPGME_CONFIG:
            conf.CHECK_CFG(path=conf.env.GPGME_CONFIG, args="--cflags --libs",
                           package="", uselib_store="gpgme",
                           msg='Checking for gpgme support')

        if conf.CHECK_FUNCS_IN('gpgme_new', 'gpgme', headers='gpgme.h'):
            conf.DEFINE('ENABLE_GPGME', '1')

        if not conf.CONFIG_SET('ENABLE_GPGME'):
            if Options.options.with_gpgme == True:
                conf.fatal('GPGME support requested, but no suitable GPGME library found, eg libgpgme11-dev and python-gpgme')
            else:
                Logs.warn('no suitable GPGME library found')
